import VueRouter from "vue-router";
import Vue from "vue";
import store from "./store";

import Home from "../pages/index/Index";
import Content from "../pages/content/Index";
import Channels from "../pages/channels/Index";
import ChannelsInfo from "../pages/channels/Info";
import Stores from "../pages/stores/Index";
import Commissioners from "../pages/commissioners/Index";
import LoanCase from "../pages/case/Index";
import LoanCaseInfo from "../pages/case/Info";
import LoanQa from "../pages/qa/index";
import LoanQaWords from "../pages/qa/words";
import LoanNews from "../pages/news/Index";
import LoanNewsInfo from "../pages/news/Info";








import Login from "../pages/login/Login";
import Signup from "../pages/login/Signup";
import UserShare from "../pages/user/Share";
import UserInvite from "../pages/user/Invite";
import UserAbout from "../pages/user/About";
import UserAccount from "../pages/user/Account";
import UserQa from "../pages/user/Qa";
import UserLoan from "../pages/user/Loan";
import UserLoanDetail from "../pages/user/LoanDetail";
import UserLoanComment from "../pages/user/LoanComment";
import UserLogMoney from "../pages/user/LogMoney";
import UserLogTicket from "../pages/user/LogTicket";
import UserKyc from "../pages/user/Kyc";
import UserWithdraw from "../pages/user/Withdraw";
import UserDeposit from "../pages/user/Deposit";
import UserLogWithdraw from "../pages/user/LogWithdraw";
// import Loan from "../pages/loan/Index";
// import LoanDetail from "../pages/loan/Detail";
import Chat from "../pages/chat/Chat";
import UserText from "../pages/user/Text";
import Wechart from "../pages/user/Wechart";
import Sqb from "../pages/user/Sqb.vue";
import UserDetail from "../../dashboard/pages/user/Detail.vue";
import UserMoneyLog from "../../dashboard/pages/user/detail/MoneyLog.vue";
import UserCallLog from "../../dashboard/pages/user/detail/CallLog.vue";
import UserTicketLog from "../../dashboard/pages/user/detail/TicketLog.vue";

Vue.use(VueRouter);

const routes = [
    {
        path: "/",
        component: Home,
        name: "home",
    },
    {
        path: "/loan/content",
        component: Content,
        name: "content",
    },
    {
        path: '/loan/channels',
        component: Channels,
        name: 'channels',

    },
    {
        path: '/loan/channels/info',
        component: ChannelsInfo,
        name: 'ChannelsInfo',
        meta: {
            breadcrumbs: [
                { text: '首页', to: '/' },
                { text: '贷款方案', to: '/loan/channels/info' }
            ]
        }
    },
    {
        path: '/loan/stores',
        component: Stores,
        name: 'stores',
        meta: {
            breadcrumbs: [
                { text: '首页', to: '/' },
                { text: '全部门店', to: '/loan/stores' }
            ]
        }
    },
    {
        path: '/loan/commissioners',
        component: Commissioners,
        name: 'commissioners',
        meta: {
            breadcrumbs: [
                { text: '首页', to: '/' },
                { text: '全部专员', to: '/loan/commissioners' }
            ]
        }
    },
    {
        path: '/loan/case',
        component: LoanCase,
        name: 'LoanCase',
        meta: {
            breadcrumbs: [
                { text: '首页', to: '/' },
                { text: '全部案例', to: '/loan/case' }
            ]
        }
    },
    {
        path: '/loan/case/info',
        component: LoanCaseInfo,
        name: 'LoanCaseInfo',
        meta: {
            breadcrumbs: [
                { text: '首页', to: '/' },
                { text: '全部案例',  to: '/loan/case' },
                { text: '案例详情', to: '/loan/case/info' }
            ]
        }
    },
    {
        path: '/loan/qa',
        component: LoanQa,
        name: 'LoanQa',
        meta: {
            breadcrumbs: [
                { text: '首页', to: '/' },
                { text: '常见问题',  to: '/loan/qa' }
            ]
        }
    },
    {
        path: '/loan/qa/words',
        component: LoanQaWords,
        name: 'LoanQaWords',
        meta: {
            breadcrumbs: [
                { text: '首页', to: '/' },
                { text: '留言',  to: '/loan/qa/words' }
            ]
        }
    },
    {
        path: '/loan/news',
        component: LoanNews,
        name: 'LoanNews',
        meta: {
            breadcrumbs: [
                { text: '首页', to: '/' },
                { text: '公司新闻',  to: '/loan/news' }
            ]
        }
    },
    {
        path: '/loan/news/info',
        component: LoanNewsInfo,
        name: 'LoanNewsInfo',
        meta: {
            breadcrumbs: [
                { text: '首页', to: '/' },
                { text: '公司新闻',  to: '/loan/news' },
                { text: '新闻详情',  to: '/loan/news/info' }
            ]
        }
    },


    // {
    //     path: "/loan/:id",
    //     component: LoanDetail,
    //     name: "loan-detail",
    // },

    // {
    //     path: "/loan",
    //     component: Loan,
    //     name: "loan",
    // },

    {
        path: "/login",
        component: Login,
        name: "login",
        meta: {
            layout: "fullpage",
        }
    },
    {
        path: "/signup",
        component: Signup,
        name: "signup",
        meta: {
            layout: "fullpage",
        }
    },
    {
        path: "/user",
        component: UserAccount,
        name: "user-account",
    },
    {
        path: "/user/share",
        component: UserShare,
        name: "user-share",
    },
    {
        path: "/user/invite",
        component: UserInvite,
        name: "user-invite",
    },
    {
        path: "/user/about",
        component: UserAbout,
        name: "user-about",
    },
    {
        path: "/user/qa",
        component: UserQa,
        name: "user-qa",
    },
    {
        path: "/user/kyc",
        component: UserKyc,
        name: "user-kyc",
    },
    {
        path: "/user/withdraw",
        component: UserWithdraw,
        name: "user-withdraw",
    },
    {
        path: "/user/text",
        component: UserText,
        name: "user-text",
    },
    {
        path: "/user/wechart",
        component: Wechart,
        name: "user-wechart",
    },
    {
        path: "/user/sqb",
        component: Sqb,
        name: "user-sqb",
    },
    {
        path: "/user/deposit",
        component: UserDeposit,
        name: "user-deposit",
    },
    {
        path: "/user/log/withdraw",
        component: UserLogWithdraw,
        name: "user-log-withdraw",
    },
    {
        path: "/user/log/money",
        component: UserLogMoney,
        name: "user-log-money",
    },
    {
        path: "/user/log/ticket",
        component: UserLogTicket,
        name: "user-log-ticket",
    },
    {
        path: "/user/loan",
        component: UserLoan,
        name: "user-loan",
    },
    {
        path: "/user/loan/:id",
        component: UserLoanDetail,
        name: "user-loan-detail",
    },
    {
        path: "/user/loan/:id/comment",
        component: UserLoanComment,
        name: "user-loan-comment",
    },
    {
        path: "/user/chat",
        component: Chat,
        name: "user-chat",
        meta: {
            layout: "fullpage",
        }
    },
];

const router = new VueRouter({
    mode: 'hash',
    routes,
    /* eslint-disable no-unused-vars */
    scrollBehavior(to, from, savedPosition) {
        // return 期望滚动到哪个的位置
        if (savedPosition) {
            return savedPosition;
        } else {
            return { x: 0, y: 0 };
        }
    }
});

/* eslint-disable no-unused-vars */
router.beforeEach((to, from, next) => {
    next();
});


/* eslint-disable no-unused-vars */
router.afterEach((to, from) => {
    if (to.meta && typeof to.meta.layout !== 'undefined') {
        store.commit("layout", to.meta.layout);
    } else {
        store.commit("layout", "default");
    }
})


export default router;
